package com.huaxin.feignclient.system;

import com.huaxin.feignclient.models.ResponseResult;
import com.huaxin.feignclient.system.models.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Set;

@Component
@FeignClient(name = "system-client", url = "${feignService.system:http://localhost:46830}")
public interface SystemClient {
    /**
     * 查询电工组织关系
     *
     * @param electricianId 电工id
     * @return 电工组织关系
     */
    @GetMapping("/v1/sys/electricianOrganizationFamily/electricianScopeList")
    ResponseResult<List<ElectricianScopeDTO>> electricianScopeList(@RequestParam("electricianId") String electricianId);

    /**
     * 获取电工档案详情
     *
     * @param id 电工id
     * @return 电工档案详情
     */
    @GetMapping("/v1/sys/electricianArchives/getElectricianArchivesDetail")
    ResponseResult<ElectricianArchives> getElectricianArchivesDetail(@RequestParam(name = "id", required = true) String id);

    /**
     * 获取用户信息
     *
     * @param userId 用户id
     * @return 用户信息
     */
    @GetMapping("/v1/sys/users/getUserInfoById")
    ResponseResult<User> getUserInfoById(@RequestParam(name = "userId", required = true) String userId);

    //获取系统用户信息
    @GetMapping("/v1/sys/sysUser/getUserInfoById")
    ResponseResult<SysUser> getSystemUserInfoById(@RequestParam(name = "userId", required = true) String userId);

    // 获取系统用户ID列表
    @GetMapping("/v1/sys/sysUser/getAllSysUserIds")
    ResponseResult<List<String>> getAllSysUserIds();

    /**
     * 根据组织code获取组织信息
     *
     * @param code 组织code
     * @return 组织信息
     */
    @GetMapping("/v1/sys/organization/getOrganizationByCode")
    ResponseResult<Organization> getOrganizationByCode(@RequestParam(name = "code", required = true) String code);

    /**
     * 根据组织ID获取组织信息
     *
     * @param id 组织ID
     * @return 组织基本信息
     */
    @GetMapping("/v1/sys/organization/getOrganizationById")
    ResponseResult<Organization> getOrganizationById(@Parameter(description = "组织ID", name = "id", required = true) @RequestParam(name = "id", required = true) String id);

    /**
     * 获取指定组织及其所有子组织的 ID 集合（含自身）
     *
     * @param orgId 组织ID
     * @return 包含自身的所有子孙组织ID集合
     */
    @GetMapping("/v1/sys/organization/getOrgAndChildrenIds")
    ResponseResult<Set<String>> getOrgAndChildrenIds(@RequestParam(name = "orgId", required = true) String orgId);

    /**
     * 根据家庭id查询家庭信息
     *
     * @param familyId 家庭id
     * @return 家庭信息
     */
    @Operation(summary = "根据家庭id查询家庭信息", description = "根据家庭id查询家庭信息")
    @GetMapping("/v1/sys/family/getFamilyById")
    ResponseResult<Family> getFamilyById(@RequestParam(name = "familyId", required = true) String familyId);

    /**
     * 获取家庭列表
     *
     * @param userId 用户ID
     * @return 家庭列表, 包含家庭成员信息
     */
    @GetMapping("/v1/sys/family/getFamilyList")
    ResponseResult<GetFamilyListRespDTO> getFamilyList(@RequestParam(name = "userId", required = true) String userId);

    /**
     * 根据家庭ID查询电工组织关系
     *
     * @param familyId 家庭ID
     * @return 电工组织关系
     */
    @GetMapping("/v1/sys/electricianOrganizationFamily/getElectriciansByFamilyIdAndOrgId")
    ResponseResult<List<String>> getElectriciansByFamilyIdAndOrgId(@Parameter(name = "familyId", description = "家庭ID") @RequestParam(value = "familyId", required = true) String familyId,
                                                                   @Parameter(name = "orgId", description = "组织ID") @RequestParam(value = "orgId", required = true) String orgId);

    /**
     * 根据组织ID查询电工组织关系
     *
     * @param orgId 组织ID
     * @return 电工组织关系
     */
    @GetMapping("/v1/sys/electricianOrganizationFamily/getElectriciansByOrgId")
    ResponseResult<List<String>> getElectriciansByOrgId(@Parameter(name = "orgId", description = "组织ID") @RequestParam(value = "orgId", required = true) String orgId);

    /**
     * 根据区域编码查询下级区域
     *
     * @param code 区域编码
     * @return 下级区域
     */
    @GetMapping("/v1/sys/national/queryNationalListByCode")
    ResponseResult<List<SysNationalAll>> queryNationalListByCode(@RequestParam(name = "code", required = true) String code);

    /**
     * 根据区域名称查询区域
     *
     * @param name 区域名称
     * @return 区域
     */
    @GetMapping("/v1/sys/national/queryNationalListByName")
    ResponseResult<List<SysNationalAll>> queryNationalListByName(@RequestParam(name = "name", required = true) String name);

    /**
     * 根据区域级别查询区域
     *
     * @param level 区域级别
     * @return 区域
     */
    @GetMapping("/v1/sys/national/queryNationalListByLevel")
    ResponseResult<List<SysNationalAll>> queryNationalListByLevel(@RequestParam(name = "level", required = true) Integer level);

    /**
     * 新增操作日志
     *
     * @param operationLog
     * @return
     */
    @Operation(summary = "新增操作日志", description = "新增操作日志")
    @PostMapping("/v1/sys/operationLog/addOperationLog")
    public ResponseResult<Boolean> addOperationLog(@RequestBody AddOperationLogReqDTO operationLog);

    /**
     * 查询字典数据
     */
    @GetMapping("/v1/sys/sysDict/querySysDictByKey")
    ResponseResult<SysDictionary> querySystemDictByKey(@Parameter(description = "字典key", name = "dictKey") @RequestParam(name = "dictKey", required = true) String dictKey);
}
